package com.lifeng.patterns.spring;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: lifeng
 * @create: 2020/9/22 14:30
 * FactoryBean 接口提供三个方法，用来创建对象
 * 可以通过FactoryBean创建某一类bean
 */
@Component
public class AnimalFactoryBean implements FactoryBean<SysUser> {

    //创建的具体bean对象的类型
    @Override
    public SysUser getObject() throws Exception {
        SysUser user = new SysUser();
        user.setName("历史");
        return user;
    }

    @Override
    public Class<?> getObjectType() {
        return SysUser.class;
    }

    //是否单例
    @Override
    public boolean isSingleton() {
        return false;
    }
}
